using System;
using System.Collections;

namespace SCSoft.WinForms.Tests
{
    public class StringArrayFixture
    {
        private readonly ArrayItem[] _items;

        public StringArrayFixture(IList list)
        {
            _items = new ArrayItem[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                var item = new ArrayItem((string) list[i], i);
                _items[i] = item;
            }
        }

        public StringArrayFixture(string[] array)
        {
            _items = new ArrayItem[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                var item = new ArrayItem(array[i], i);
                _items[i] = item;
            }
        }

        public object[] Query()
        {
            return _items;
        }

        public Type GetTargetClass()
        {
            return typeof (ArrayItem);
        }
    }

    public class ArrayItem
    {
        private string _value;

        public ArrayItem(string value, int index)
        {
            _value = value;
            Index = index;
        }

        public string TradeId
        {
            get { return _value; }
            set { _value = value; }
        }

        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public int Index { get; set; }

        public int Row
        {
            get { return Index; }
            set { Index = value; }
        }
    }
}